s = sorted(map(lambda n:n[1:-1], open('22.names.txt', 'rb').read().split(',')))

def score(n):
    ret = 0
    for c in n:
        ret += ord(c) - ord('A') + 1
    return ret

print s.index('COLIN'), score('COLIN')

total = 0
for i in range(len(s)):
    total += score(s[i]) * (i + 1)
print total